<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@page import="java.util.Collection" %>
<%@page import="java.util.Iterator" %>
<%@page import="com.liuya.safe.entitle.handler.DecisionEntitlementHandler" %>
<%@page import="com.liuya.safe.model.SafePrivilege" %>
<%@page import="com.liuya.safe.model.SafeDecisionEntitlement" %>
<%@ page import="com.liuya.common.I18N" %>

<%
    I18N i18n = I18N.getInstance();
    DecisionEntitlementHandler handler = (DecisionEntitlementHandler) request.getAttribute("handler");
    String id = request.getParameter("id");

    SafePrivilege pvlg = handler.getPrivilege();
    Collection entitlements = handler.getDecisionEntitlements();
%>

<table class="ralaTable">
    <tr>
        <th><%=i18n.say("Effect")%>
        </th>
        <th><%=i18n.say("User_category")%>
        </th>
        <th><%=i18n.say("Business_data")%>
        </th>
        <th><%=i18n.say("Deny_reason")%>
        </th>
        <th><%=i18n.say("Action")%>
            <a href="javascript:addEntitle()" title="<%=i18n.say("Add") %>"><img src="${contextPath}/style/images/add.gif"/></a>
        </th>
    </tr>
    <%
        int i = -1;
        for (Iterator iter = entitlements.iterator(); iter.hasNext(); ) {
            SafeDecisionEntitlement entitle = (SafeDecisionEntitlement) iter.next();
            i++;
    %>
    <tr>
        <td><%=i18n.say(entitle.getEffect()) %>
        </td>
        <td><%=entitle.getUserCategory().getName() %>
        </td>
        <td><%=entitle.getBusinessData().getName() %>
        </td>
        <td><%=entitle.getDenyReason() %>
        </td>
        <td><a href="javascript:moveEntitle('top', <%=i%>);" title="<%=i18n.say("Top") %>"><img
                src="${contextPath}/style/images/top.gif"/></a>
            <a href="javascript:moveEntitle('up', <%=i%>);" title="<%=i18n.say("Up") %>"><img
                    src="${contextPath}/style/images/up.gif"/></a>
            <a href="javascript:moveEntitle('down', <%=i%>);" title="<%=i18n.say("Down") %>"><img
                    src="${contextPath}/style/images/down.gif"/></a>
            <a href="javascript:moveEntitle('bottom', <%=i%>);" title="<%=i18n.say("Bottom") %>"><img
                    src="${contextPath}/style/images/bottom.gif"/></a>
            <a href="javascript:editEntitle(<%=i %>, <%=i%>);" title="<%=i18n.say("Edit") %>"><img
                    src="${contextPath}/style/images/edit.gif"/></a>
            <a href="javascript:deleteEntitle(<%=i%>);" title="<%=i18n.say("Delete") %>"><img
                    src="${contextPath}/style/images/delete.gif"/></a></td>
    </tr>
    <% } %>
</table>